using System.Threading;
using System.Threading.Tasks;
using MediatR;
using B.S.BasicData.EroorCode;
using B.S.BasicData.Domain;
using B.S.BasicData.Infrature;

public class ProindexinfoGetByIdHandler : IRequestHandler<ProindexinfoGetByIdRequest, ApiResult<Proindexinfo>>
{
    private readonly IBaseRepository<Proindexinfo> _repository;
    public ProindexinfoGetByIdHandler(IBaseRepository<Proindexinfo> repository)
    {
        _repository = repository;
    }

    public async Task<ApiResult<Proindexinfo>> Handle(ProindexinfoGetByIdRequest request, CancellationToken cancellationToken)
    {
        var entity = await _repository.GetByIdAsync(request.Id);
        if (entity == null || entity.IsDeleted)
            return ApiResult<Proindexinfo>.Fail("未找到数据");
        return ApiResult<Proindexinfo>.Success(entity, "查询成功");
    }
} 